package com.able.concurrency.t1;

import java.util.concurrent.TimeUnit;

/**
 * @author abel.he
 * @data 2018/8/15 19:16
 * @describe 子类同步方法覆盖父类同步方法，可以指定调用父类的同步方法，相当于锁的重入
 */
public class Test7 {

    synchronized void m1 () {
        System.out.println("father start");
        try {
            TimeUnit.SECONDS.sleep(2);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("father end");
    }

    public static void main(String[] args) {
        new Sub().m1();
    }

}

class Sub extends Test7{
    synchronized void m1() {
        System.out.println("sub start");
        super.m1();
        System.out.println("sub end");
    }
}
